
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : Mqcpalldefine.h
  * @brief          :  Mqcp alldefine
  ******************************************************************************
  * @attention
  * 本文件用于  MQCP结构体
  * @20210414:文件模板第一次生成
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MQCP_DEFINE_H_
#define __MQCP_DEFINE_H_



/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#include "main.h"
#include "SysCrc.h"

/* USER CODE END Includes */

/* Exported define ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

//上报参数个数
#define Data2Size 160 //128
#define Data4Size 80 //68

/*当前使用的版本号*/
#define MQCP_USE_VER	3

/*时间校验*/
#define TimeReq								0X01//device
#define TimeResp							0X81//server
/*设备信息*/
#define DeviceInfoReportReq		0x02//device
#define DeviceInfoReportResp	0x82//server
/*获取模板*/
#define TemplateReq 					0x03//device
#define TemplateResp					0x83//server
/*定时任务*/			
//定时任务主动上报			
#define TaskReportReq					0x10//device
#define TaskReportResp				0x90//server
//获取定时任务
#define TaskGetReq						0x11//server
#define TaskGetResp 					0x91//device
//添加定时任务			
#define TaskAddReq						0x12//server
#define TaskAddResp						0x92//device
//修改定时任务			
#define TaskUpdateReq					0x13//server
#define TaskUpdateResp 				0x93//device
//删除定时任务			
#define TaskDelReq						0x14//server
#define TaskDelResp						0x94//device
/*寄存器*/			
//寄存器主动上报			
#define RegReportReq					0x20//device
#define RegReportResp 				0xA0//server
//读寄存器			
#define RegReadReq 						0x21//server
#define RegReadResp  					0xA1//device
//写寄存器			
#define RegWriteReq 					0x22//server
#define RegWriteResp  				0xA2//device
//全开全关			
#define CtrlAllReq 						0x23//server
#define CtrlAllResp  					0xA3//device

//上线提示
#define MqcpOnline						0x51//server
//离线提示
#define MqcpOffline  					0xD1//device
/* USER CODE END ET */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

typedef  enum
{
	MqcpBool = 0,
	MqcpInt16,
	MqcpUint16,
	MqcpInt32,
	MqcpUint32,
	MqcpFloat32 = 6,
	MqcpEnum = 8
}ValueType;

typedef enum
{
	MqcpSyncFalse = 0,
	MqcpSyncTrue
}SyncState;

typedef enum
{
	MqcpCodeOK = 0,
	MqcpCodeError
}CodeState;

typedef enum
{
	TimeListUpDate = 0,
	TimeListAdd,
	TimeListDel
}TaskTimeListState;
/********
*
*		uint8_t			MsgID[12];	消息号: 8字节时间戳+4字节设备ID, 共12字节, 小端																	
*		uint8_t			Sync;				同步标识:1字节bool 0:false, !0:true
*		uint8_t			Code;				状态码
*		uint8_t			Ver;				协议版本号
*		uint8_t			Length[2];	Data区长度
*	
*		uint8_t 		DevID[4];		设备Id
*	
*		uint8_t			CMD;				命令字
*		uint8_t   	Data[490];	数据区
*	
*		uint8_t			Xor;				整帧异或校验
********/
typedef struct
{
	uint8_t	MsgId[12];	//消息号
	uint8_t	Sync;		//同步表示
	uint8_t	Code;		//状态码
	uint8_t	Ver;		//协议版本号
	uint8_t	Len[2];		//data区长度
	uint8_t	DevID[4];		//设备id
	uint8_t	Cmd;		//命令字
	uint8_t Data[1024+256];		//数据区与校验
}MqcpMessageDef;

typedef struct
{
	uint8_t 				isNeedResp;
	uint16_t				Size;
	MqcpMessageDef	MqcpMessage;
}MqcpDataDef;

typedef struct
{
	uint32_t	DevId;
	uint32_t	DevSn;
	uint8_t 	DevKey[16];
}MqcpDeviceDef;

typedef struct
{
	uint16_t	NetOnline;
	uint16_t	CSQ;
	uint8_t		ICCID[20];
	uint8_t 	Connect;
}MqcpNetDef;

typedef struct 
{
		uint8_t  Type;
    uint16_t Address;
    uint16_t  Data;
}Data2ByteDef;

typedef struct 
{
		uint8_t  Type;
    uint16_t Address;
    uint16_t  Data[2];
}Data4ByteDef;

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */







/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */









/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/






/* USER CODE BEGIN EFP */

/* USER CODE END EFP */



#endif /* __DO_TASK_H */

/************************ (C) COPYRIGHT CunJu *****END OF FILE****/
